package ar.edu.itba.cg.controllers;

import com.jme.curve.Curve;
import com.jme.curve.CurveController;
import com.jme.math.Vector3f;
import com.jme.scene.Spatial;

public class ShootController extends CurveController{
	private static final long serialVersionUID = 1L;

	private Spatial mover;
	
	private float max;
	private float min;
	
	private Vector3f minPoint;
	private Vector3f maxPoint;
	private float distance;
	
	public ShootController(Curve curve, Spatial mover, float min, float max, Vector3f minPoint, Vector3f maxPoint) {
		super(curve, mover);
		this.mover=mover;
		this.min= min;
		this.max= max;
		
		this.minPoint= new Vector3f(minPoint);
		this.maxPoint= new Vector3f(maxPoint);
		
		distance= maxPoint.distance(minPoint);
		System.out.println("min point: " + minPoint + " max point: " + maxPoint + "seteo distancia: "  + distance);
	}
	
	public Vector3f getPosition(){
		return mover.getLocalTranslation();
	}
	
	public float getValue(){
		Vector3f posMover= mover.getLocalTranslation();
		float pos= minPoint.distance(posMover);
		float ans= min + (max-min)*(pos/distance);
		System.out.println("pos: " + pos + " min: " + min + " max: " + max+ " distance: " + distance);
		System.out.println("position: " + ans);
		return ans;
	}

	
}
